Skip to content

Решение к домашней работе Fragments#63

Open
dbulygin wants to merge 2 commits intoAndroid-Developer-Basic:masterfrom
dbulygin:master
Open

Решение к домашней работе Fragments#63
dbulygin wants to merge 2 commits intoAndroid-Developer-Basic:masterfrom
dbulygin:master

Conversation

@dbulygin
Copy link

No description provided.

): View {
_binding = FragmentAaBinding.inflate(inflater, container, false)
val view = binding.root
binding.containerAA.setBackgroundColor(ColorGenerator.generateColor())

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Сейчас цвет генерируется внутри AA, а по заданию должен передаваться через аргументы при создании фрагмента в методе openFragmentAA фрагмента А. Используйте bundleOf для создания аргументов и получите его в АА

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Исправил


private fun openFragmentAB() {
val fragmentAB = FragmentAB()
parentFragmentManager.beginTransaction()
Copy link

@Lufavetskaya Lufavetskaya Nov 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Сейчас используется parent, что делает AB стблинг A, а не чайлд. Нужно использовать childFragmentManager, чтобы AB был чайлд А. Также цвет должен передаваться через аргументы, как в пункте выше.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Исправил на childFragmentManager


private fun openFragmentBB() {
val fragmentBB = FragmentBB()
childFragmentManager.beginTransaction()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тут наоборот использовать parentFragmentManager, чтобы фрагменты были на одном уровне в иерархии
ТЗ: будет открываться FragmentBB, на том же уровне
иерархии, что и **FragmentBA

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Исправил на parentFragmentManager

}
}

private fun openFragmentBA() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

После отправки цвета из BB нужно вернуться назад через popBackStack(), а не создавать новый BA

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Готово

@dbulygin
Copy link
Author

Исправления внесены.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants